<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>约瑟夫环问题 - 经典算法解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f9fafb;
            color: #1f2937;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        }
        .code-block {
            background-color: #1e293b;
            border-left: 4px solid #3b82f6;
        }
        .concept-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
            z-index: 1;
        }
        .highlight::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(59, 130, 246, 0.2);
            z-index: -1;
            transform: skewY(-2deg);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:py-32">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">约瑟夫环问题</h1>
                    <p class="text-xl md:text-2xl mb-6 opacity-90">经典算法问题的优雅解法</p>
                    <div class="bg-white bg-opacity-20 p-4 rounded-lg backdrop-blur-sm inline-block">
                        <p class="text-lg">"n个人围成一圈，从第一个人开始报数，数到m的人出列...求最后幸存者的编号"</p>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid text-white">
                        graph LR
                        A[1] --> B[2] --> C[3] --> D[4] --> E[5] --> A
                        style A fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
                        style B fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
                        style C fill:#ef4444,stroke:#b91c1c,stroke-width:2px,color:#fff
                        style D fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
                        style E fill:#3b82f6,stroke:#1e40af,stroke-width:2px,color:#fff
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl px-4 py-12">
        <!-- Problem Description -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="bg-blue-100 p-3 rounded-full mr-4">
                    <i class="fas fa-question-circle text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif highlight">题目描述</h2>
            </div>
            <div class="bg-white rounded-xl shadow-md p-6">
                <p class="text-lg leading-relaxed">
                    n 个人围成一圈，从第一个人开始报数，数到 m 的人出列，然后从下一个人重新开始报数，直到所有人都出列。求最后一个出列的人的编号（从 1 开始）。
                </p>
                <div class="mt-4">
                    <p class="text-gray-600">
                        <i class="fas fa-lightbulb text-yellow-500 mr-2"></i> 例如，当 n = 5, m = 3 时，出列顺序是 3, 1, 5, 2, 4，所以最后一个出列的人的编号是 4。
                    </p>
                </div>
            </div>
        </section>

        <!-- Solution Approaches -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="bg-purple-100 p-3 rounded-full mr-4">
                    <i class="fas fa-brain text-purple-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold font-serif highlight">解法思路</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-6">
                <!-- Circular Linked List Method -->
                <div class="concept-card bg-white rounded-xl shadow-md p-6 transition-all duration-300">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 p-2 rounded-full mr-3">
                            <i class="fas fa-link text-green-600"></i>
                        </div>
                        <h3 class="text-xl font-bold">环形链表法</h3>
                    </div>
                    <p class="text-gray-700 mb-4">构建环形链表，模拟报数过程，每次删除第 m 个节点，直到只剩下一个节点。</p>
                    <div class="flex items-center text-sm text-gray-500">
                        <div class="mr-4">
                            <i class="fas fa-clock mr-1"></i> O(n*m)
                        </div>
                        <div>
                            <i class="fas fa-memory mr-1"></i> O(n)
                        </div>
